package com.linkit.main;

import android.view.View;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;

import com.linkit.main.widget.HeaderLayout;

public class ContentManager {
	private MainActivity main;
	
	/** Button header menu */
	private HeaderLayout headerLayout;
	
	/** Lưu trữ layout hiện thị nội dung của ứng dụng */
	private RelativeLayout contentLayout;
	
	/** Lưu trữ layout hiện thị nội dung của ứng dụng */
	private RelativeLayout subContentLayout;
	
	/**Lưu trữ giao diện thông tin quảng cáo*/
	public RelativeLayout advLayout;

	public ContentManager(MainActivity activity) {
		main = activity;
		headerLayout = (HeaderLayout) main.findViewById(R.id.header);
		contentLayout = (RelativeLayout)main.findViewById(R.id.content_layout);
		subContentLayout = (RelativeLayout)main.findViewById(R.id.sub_content_layout);
		advLayout = (RelativeLayout)main.findViewById(R.id.adv_content_layout);
	}
	
	//thêm nội dung vào layout
	public void addContentLayout(View view){
		RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
		contentLayout.setLayoutParams(params);
		contentLayout.addView(view);
		contentLayout.setVisibility(View.VISIBLE);
		removeSubContentlayout();
	}

	//thêm nội dung vào layout
	public void addSubContentLayout(View view){
		subContentLayout.removeAllViews();
		RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
		subContentLayout.setLayoutParams(params);
		subContentLayout.addView(view);
		subContentLayout.setVisibility(View.VISIBLE);
	}
	
	//thêm nội dung vào layout
	public void addSubContentLayout(View view, LayoutParams params){
		subContentLayout.removeAllViews();
		subContentLayout.addView(view);
		subContentLayout.setLayoutParams(params);
		subContentLayout.setVisibility(View.VISIBLE);
	}
	
	/**
	 * Xóa nội dung của layout
	 */
	public void removeSubContentlayout(){
		subContentLayout.setVisibility(View.GONE);
		subContentLayout.removeAllViews();
	}

	public HeaderLayout getHeaderLayout() {
		return headerLayout;
	}

	public RelativeLayout getContentLayout() {
		return contentLayout;
	}
}
